package com.yanglei.demo.controller;

import com.yanglei.demo.client.UserClient;
import com.yanglei.demo.client.dto.CommonResult;
import com.yanglei.demo.client.dto.oauth2.OAuth2AccessTokenRespDTO;
import com.yanglei.demo.client.dto.user.OAuth2UserInfoRespDTO;
import com.yanglei.demo.client.dto.user.UserUpdateReqDTO;
import com.yanglei.demo.framework.LoginUser;
import com.yanglei.demo.framework.core.util.SecurityUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author hljstart
 * @Date 2025/11/4 20:38
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserClient userClient;

    @GetMapping("/get")
    public CommonResult<OAuth2UserInfoRespDTO> get() {
        return userClient.getUserInfo();
    }


    @PutMapping("/update")
    public CommonResult<Boolean> updateNickname(@RequestParam("nickname") String nickname) {
        UserUpdateReqDTO updateReqDTO = new UserUpdateReqDTO(nickname, null, null, null);
        return userClient.update(updateReqDTO);
    }
}
